package com.bb.blog.code.nio;

import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.nio.charset.StandardCharsets;

public class Client {
    public static void main(String[] args) {
        Socket socket = new Socket();
        try {
            socket.connect(new InetSocketAddress(6000),60);
            socket.getOutputStream().write("xixixi".getBytes(StandardCharsets.UTF_8));
            InputStream inputStream = socket.getInputStream();
            byte[] result =new  byte[1024];
            inputStream.read(result);
            System.out.println(new String(result));
            socket.getOutputStream().write("xixixi".getBytes(StandardCharsets.UTF_8));
            InputStream inputStream2 = socket.getInputStream();
            byte[] result2 =new  byte[1024];
            inputStream2.read(result2);
            System.out.println(new String(result2));
            socket.close();


        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
